package com.tanhua.server.service;

import com.tanhua.dubbo.api.UserLocationApi;
import com.tanhua.model.vo.ErrorResult;
import com.tanhua.server.exception.BusinessException;
import com.tanhua.server.interceptor.UserHolder;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

@Service
public class BaiduService {

    @DubboReference
    private UserLocationApi userLocationApi;

    /**
     * 上传地理位置
     * longitude 经度
     * latitude  纬度
     * addrStr  地理信息
     * @return
     */
    public void location(Double longitude, Double latitude, String addrStr) {
        //调用api更新地理位置
        Boolean aBoolean = userLocationApi.updateLocation(UserHolder.getUserId(), longitude, latitude, addrStr);
        if (!aBoolean) {
            throw new BusinessException(ErrorResult.error());
        }
    }
}
